package algorithm;


public class T00026 {
    public static void main(String[] args) {
        int[] nums = {-1,1,1};
        int len = new Solution().removeDuplicates(nums);
        for (int i = 0; i < len; i++) {
            System.out.println(nums[i]);
        }
    }

static class Solution {
    public int removeDuplicates(int[] nums) {
        final int l;
        if(nums == null || (l = nums.length) == 0)
            return 0;
        int c = 0;
        int p = 0;
        while(p < l) {
            if(nums[c] == nums[p])
                p ++;
            else
                nums[++ c] = nums[p ++];
        }
        return c + 1;
    }
}
}